home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d20
/
doorskl3.arc
/
MTASK.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-01-15
|
4KB
|
184 lines
/**********************************************************/
/* Functions to help DOORSKEL get along with multitaskers */
/* and other mumbo-jumbo */
/**********************************************************/
#include "doorskel.h"
static union REGS rg;
static int mtask = 0; /* type of multitasker, if any */
#define DVID 1
#define DDOSID 2
#define MOSID 3
#define TVID 4
#define OS2ID 5
static int _fastcall is_dv (void);
static int _fastcall is_ddos (void);
static int _fastcall is_mos (void);
static int _fastcall is_tv (void);
static int _fastcall is_os2 (void);
static void _fastcall pause_dv (void);
static void _fastcall pause_ddos (void);
static void _fastcall pause_tv (void);
static void _fastcall pause_mos (void);
static void _fastcall pause_os2 (void);
void _fastcall set_mtask (void) {
if(is_dv()) mtask=DVID;
else if(is_ddos()) mtask = DDOSID;
else if(is_mos()) mtask = MOSID;
else if(is_tv()) mtask = TVID;
else if(is_os2()) mtask = OS2ID;
}
static int _fastcall is_dv (void) {
rg.x.cx=0x04445;
rg.x.dx=0x05351;
rg.x.ax=0x02b01;
int86(0x21,&rg,&rg);
if(rg.h.al==0x0ff) return 0;
return rg.x.bx;
}
static int _fastcall is_ddos (void) {
rg.h.ah=0x0e4;
int86(0x21,&rg,&rg);
if(rg.h.al==1 || rg.h.al==2) return 1;
return 0;
}
static int _fastcall is_mos (void) {
int temp;
rg.h.ah=0x030;
int86(0x21,&rg,&rg);
temp=rg.x.ax;
rg.x.ax=0x03000;
rg.x.bx=0x03000;
rg.x.cx=0x03000;
rg.x.dx=0x03000;
int86(0x21,&rg,&rg);
if(rg.x.ax==temp) return temp;
return 0;
}
static int _fastcall is_tv (void) {
rg.x.ax=0x01022;
rg.x.bx=0;
int86(0x15,&rg,&rg);
if(!rg.x.bx) return 0;
return rg.x.bx;
}
static int _fastcall is_os2 (void) {
rg.x.ax = 0x1680;
int86(0x2f,&rg,&rg);
return (rg.h.al == 0);
}
static void _fastcall pause_dv (void) {
rg.x.ax = 0x0101a;
int86(0x15,&rg,&rg);
rg.x.ax = 0x01000;
int86(0x15,&rg,&rg);
rg.x.ax = 0x01025;
int86(0x15,&rg,&rg);
}
static void _fastcall pause_ddos (void) {
int86(0xf4,&rg,&rg);
}
static void _fastcall pause_tv (void) {
rg.x.ax = 0x01000;
int86(0x15,&rg,&rg);
}
static void _fastcall pause_mos (void) {
rg.x.ax = 0x0703;
rg.x.bx = 0x03;
rg.x.cx = 0;
rg.x.dx = 0;
int86(0x38,&rg,&rg);
}
static void _fastcall pause_os2 (void) {
rg.x.ax = 0x1680;
int86(x2f,&rg,&rg);
}
void _fastcall pause_mtask (void) {
switch(mtask) {
case 0: break;
case DVID: pause_dv();
break;
case DDOSID: pause_ddos();
break;
case TVID: pause_tv();
break;
case MOSID: pause_mos();
break;
case OS2ID: pause_os2();
break;
default: break;
}
int86(0x28,&rg,&rg); /* DOS scheduler interrupt */
}
void _fastcall my_sleep (int secs) { /* snooze a while */
clock_t t1;
t1 = clock() + ((clock_t)secs * (clock_t)CLOCKS_PER_SEC);
while(clock() < t1) pause_mtask();
}
void _fastcall DosSleep (clock_t millisecs) { /* snooze a short while */
clock_t t1;
t1 = clock() + millisecs;
while(clock() < t1) pause_mtask();
}